package logic

import (
	"context"
	"hzjt-oam/rpc/sys/internal/svc"
	"hzjt-oam/rpc/sys/model"
	"hzjt-oam/rpc/sys/pb"
	"time"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddSysRoleDeptLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddSysRoleDeptLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddSysRoleDeptLogic {
	return &AddSysRoleDeptLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// -----------------------角色机构-----------------------
func (l *AddSysRoleDeptLogic) AddSysRoleDept(in *pb.AddSysRoleDeptReq) (*pb.AddSysRoleDeptResp, error) {
	var sys_dept_role = &model.SysRoleDept{
		RoleId:         in.RoleId,
		DeptId:         in.DeptId,
		CreateBy:       in.CreateBy,
		CreateTime:     time.Now().Unix(),
		LastUpdateBy:   in.CreateBy,
		LastUpdateTime: time.Now().Unix(),
	}
	_, _ = l.svcCtx.RoleDeptModel.Insert(l.ctx, sys_dept_role)

	return &pb.AddSysRoleDeptResp{}, nil
}
